//
//  MainViewController.swift
//  Sina(微博)
//
//  Created by mac on 15/12/12.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    let mainTabBar = MainTabBar()
    //mainTabBarButton的点击事件
    @objc private func composButtonClick() {
       print("点击了")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        mainTabBar.composeBtn.addTarget(self, action: "composButtonClick", forControlEvents: UIControlEvents.TouchUpInside)
        setValue(mainTabBar, forKey: "tabBar")
        
        addChildViewControllers()
        
    }
    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), title: "首页", imageName:"tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "个人信息", imageName: "tabbar_profile")
        
        
    }
    
    private func addChildViewController(viewController: UIViewController,title: String,imageName: String) {
        let nav = UINavigationController(rootViewController: viewController)
        viewController.title = title
        viewController.tabBarItem.image = UIImage(named: imageName)
        
        self.addChildViewController(nav)
    }
}
